#define _CRT_SECURE_NO_WARNINGS 1

#include"sort.h"

void TestOP()
{
	srand((unsigned int)time(0));
	const int N = 1000000;
	int* a1 = (int*)malloc(sizeof(int)*N);
	int* a2 = (int*)malloc(sizeof(int)*N);
	int* a3 = (int*)malloc(sizeof(int)*N);
	int* a4 = (int*)malloc(sizeof(int)*N);
	int* a5 = (int*)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
	}

	//int begin1 = clock();
	//InsertSort(a1, N);
	//int end1 = clock();

	int begin2 = clock();
	ShellSort(a2, N);
	int end2 = clock();


	//for (int i = (N - 2) / 2; i >= 0; i--)
	//{
	//	AdjustDown(a3, N, i);
	//}
	//int begin3 = clock();
	//BubbleSort(a3, N);
	//int end3 = clock();

	int begin4 = clock();
	QuickSort(a4, 0, N - 1);
	int end4 = clock();

	//printf("InsertSort:%d\n", end1 - begin1);
	printf("ShellSort:%d\n", end2 - begin2);
	//printf("BubbleSort:%d\n", end3 - begin3);
	printf("QuickSort:%d\n", end4 - begin4);
}

void main()
{	
	MergeSortFile("file.txt");

	//int a[] = { 9, 1, 2, 5, 7, 4, 8, 6, 3, 5 };
	////int a[] = { 20, 10, 8, 5, 4, 7, 3 };
	////int a[] = { 6, 1, 2, 7, 9, 3, 4, 8, 10, 5 };
	//PrintArray(a, sizeof(a) / sizeof(a[0]));

	////for (int i = (sizeof(a) / sizeof(a[0]) - 2) / 2; i >= 0; i--)
	////{
	////	AdjustDown(a, sizeof(a) / sizeof(a[0]), i);
	////}
	////int a[] = {5,4,3,2,1};
	////MergeSortNonR(a, sizeof(a) / sizeof(a[0]));
	//CountSort(a, sizeof(a) / sizeof(a[0]));
	////MergeSort(a, sizeof(a) / sizeof(a[0]));
	////MergeSortNonR(a, sizeof(a) / sizeof(a[0]));
	////QuickSort(a, 0, sizeof(a) / sizeof(a[0]) - 1);
	////QuickSortNonR(a, 0, sizeof(a) / sizeof(a[0]) - 1);
	////BubbleSort(a, sizeof(a) / sizeof(a[0]));
	////HeapSort(a, sizeof(a) / sizeof(a[0]));
	////SelectSort(a, sizeof(a) / sizeof(a[0]));
	////InsertSort(a, sizeof(a) / sizeof(a[0]));
	////ShellSort(a, sizeof(a) / sizeof(a[0]));
	//PrintArray(a, sizeof(a) / sizeof(a[0]));
	////TestOP();
}